package org.travel_system.mapper;

import org.apache.ibatis.annotations.*;
import org.travel_system.pojo.Admin;

@Mapper
public interface AdminMapper {

    //查询管理员
    @Select("SELECT * FROM admin WHERE username = #{adminName}")
    Admin findAdminByName(String adminName);

    //注册管理员
    @Insert("insert into admin(username, password, manager_type) values(#{username}, #{password}, 0)")
    int register(String username, String password);

    //更新管理员信息
    @Update("update admin set manager_type=#{admin.managerType} where username=#{username}")
    int updateAdminInfo(@Param("username") String username, @Param("admin") Admin admin);

    //更新管理员密码
    @Update("update admin set password=#{newPwd} where username=#{username}")
    int updatePwd(String username, String newPwd);

    //查询id
    @Select("SELECT manager_id as id FROM admin WHERE username = #{username}")
    Integer findAdminId(String username);
}
